home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SATAN11.ZIP / SRC / FPING / README.VMS / text0000.txt < prev   
Encoding:
Text File  |  1995-03-15  |  4.9 KB  |  160 lines

  1. Hello,
  2.  
  3. I rather liked your recently posted fping, and I decided to port it to VMS,
  4. under MultiNet TCP/IP 3.0H and VAXC 3.2. Only some very minor modifications are
  5. necessary to run it under VMS 5.5: 
  6.  
  7. 1) The 2 following lines must be put onto one single line, otherwise VAXC 
  8. complains:
  9.  
  10. #if !__STDC__ && !defined(__cplusplus) && !defined(FUNCPROTO) \
  11.                                                  && !defined(_POSIX_SOURCE)
  12.  
  13. goes to:
  14.  
  15. #if !__STDC__ && !defined(__cplusplus) && !defined(FUNCPROTO) && !defined(_POSIX_SOURCE)
  16.  
  17. 2) The single following line must be changed:
  18.  
  19. extern char *sys_errlist[];
  20.  
  21. to:
  22.  
  23. #ifndef VMS
  24. extern char *sys_errlist[];
  25. #else
  26. extern noshare char *sys_errlist[];
  27. #endif
  28.  
  29. 3) VMS runs privileged programs in a different manner from UNIX. geteuid is 
  30. "supported" by VAXC but the result is not really meaningful.
  31.  
  32. These lines are thus Unix specific:
  33.  
  34.   /* check if we are root */
  35.  
  36. #ifndef VMS
  37.   if (geteuid()) {
  38.       fprintf(stderr,
  39.         "This program can only be run by root, or it must be setuid root.\n");
  40.       exit(3);
  41.   }
  42. #endif
  43.  
  44. 4) VAXC does not support getopt. I got my copies of getopt, index and rindex
  45. from a fileserver with bsd-sources, using anonymous FTP. These routines
  46. compiled without complaints and works fine under VAXC 3.2 at least. 
  47.  
  48. 5) The VMS concept of exit codes is different from the Unix version. After some
  49. thought I decided to short circuit the VAXC attempt of translating the Unix
  50. return codes into VMS style return codes. My version of FPING always returns
  51. "exit(1)", which is VMS success. However the FPING status codes are put into a
  52. VMS symbol, FPING_STATUS. It is thus very easy to use the FPING return status
  53. codes for further action if needed. 
  54.  
  55. The line at the end of main in FPING, "return 0;", must be changed to
  56. "exit(0);" for VMS, this should be OK for Unix too?
  57.  
  58. A small routine is needed to handle the translation, it will probably not
  59. get any rewards for nice C-code (I usually program in Fortran), and it was 
  60. largely created by copying an example from the VAXC manuals:
  61.  
  62. /* VMS-EXIT.C */
  63. #include <ssdef>
  64. #include <stdio>
  65. #include <descrip>
  66.  
  67. int LIB$SET_SYMBOL();
  68.  
  69. vms_exit (ecode)
  70. int ecode;
  71. {
  72.   int status = 1;
  73.   static $DESCRIPTOR(fping_name, "FPING_STATUS");
  74.   static $DESCRIPTOR(fping_exit_0,"0");
  75.   static $DESCRIPTOR(fping_exit_1,"1");
  76.   static $DESCRIPTOR(fping_exit_2,"2");
  77.   static $DESCRIPTOR(fping_exit_3,"3");
  78.   static $DESCRIPTOR(fping_exit_4,"4");
  79.   static $DESCRIPTOR(fping_exit_5,"5");
  80.  
  81.   switch(ecode) {
  82.   case 0 :
  83.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_0);
  84.     break;
  85.   case 1 :
  86.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_1);
  87.     break;
  88.   case 2 :
  89.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_2);
  90.     break;
  91.   case 3 :
  92.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_3);
  93.     break;
  94.   case 4 :
  95.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_4);
  96.     break;
  97.   default:
  98.     status = LIB$SET_SYMBOL(&fping_name,&fping_exit_5);
  99.     break;
  100.   }
  101.  
  102.   exit(1);
  103.  
  104. }
  105.  
  106.  
  107. 6) The following command file (script) was used to compile and link under VMS:
  108.  
  109. $! VMS-CC-MAKE.COM
  110. $! 
  111. $! This compile+link procedure has been tested with VAXC 3.2 and
  112. $! MultiNet 3.0H.
  113. $!
  114. $! NOTE: getopt, index, and rindex are not part of VAXC, however the BSD
  115. $! versions works fine. They should be available by anonymous FTP
  116. $! from a number of fileservers.
  117. $!
  118. $ define/user arpa             multinet_root:[multinet.include.arpa]
  119. $ define/user netinet          multinet_root:[multinet.include.netinet]
  120. $ define/user sys              multinet_root:[multinet.include.sys],sys$library
  121. $ cc /nolist /define="exit=vms_exit" fping.c
  122. $ cc /nolist                         vms-exit.c
  123. $ cc /nolist                         getopt.c
  124. $ cc /nolist                         index.c
  125. $ cc /nolist                         rindex.c
  126. $ link /nomap/notrace fping,vms-exit,getopt,index,rindex,sys$input/opt
  127. multinet:multinet_socket_library/share
  128. sys$share:vaxcrtl/share
  129. $ delete fping.obj.*,vms-exit.obj.*,getopt.obj.*,index.obj.*,rindex.obj.*
  130. $ purge  fping.exe
  131. $ fping :== $'f$environment("default")'fping
  132.  
  133. 7) Piping files into fping is not available under VMS, but the "f" option does
  134. the same job.
  135.  
  136. 8) fping must be installed with privileges if it is to be used by
  137. non-privileged users under VMS. 
  138.  
  139. The question then is, does it work? Well, as far I can see the answer is yes!
  140. Here are some examples of output:
  141.  
  142. $ fping xxx
  143. xxx address not found
  144. $ show symbol fping_status
  145.   FPING_STATUS = "2"
  146. $ fping vxcrna.cern.ch
  147. vxcrna.cern.ch is alive
  148. $ show symbol fping_status
  149.   FPING_STATUS = "0"
  150. $ fping -de vxcrna.cern.ch
  151. vxcrna.cern.ch is alive (320 msec)
  152. $ show symbol fping_status
  153.   FPING_STATUS = "0"
  154. $ fping -v
  155. vsfys5$dkb100:[scratch.iversen]fping.exe;7: $Revision: 1.17 $ $Date: 1992/07/23 03:29:42 $
  156. vsfys5$dkb100:[scratch.iversen]fping.exe;7: comments to schemers@Stanford.EDU
  157.  
  158. Regards, Per (iversen@vsfys1.fi.uib.no)
  159.  
  160.